aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/sujet/[slug].tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-12-20 00:15:20 +0100
committerArmand Philippot <git@armandphilippot.com>2021-12-20 00:15:20 +0100
commitfa6adedc42e9c6ec39cc30df16b54900c220b094 (patch)
tree6bb498beadaa382245cecb86ce56931580313c6f /src/pages/sujet/[slug].tsx
parent2ff898626c5c0abc6b8195224067b992403e313b (diff)
refactor: rewrite types and services
I was repeating myself a lot in services. So I rewrited the different functions to improve readability and I extracted some formatting functions to put them in utils. I also rewrited/reorganized some types to keep consistent names.
Diffstat (limited to 'src/pages/sujet/[slug].tsx')
-rw-r--r--src/pages/sujet/[slug].tsx11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx
index a6acf2b..4dc4e9b 100644
--- a/src/pages/sujet/[slug].tsx
+++ b/src/pages/sujet/[slug].tsx
@@ -1,10 +1,6 @@
import Layout from '@components/Layouts/Layout';
import PostPreview from '@components/PostPreview/PostPreview';
import { t } from '@lingui/macro';
-import {
- fetchAllSubjectsSlug,
- getSubjectBySlug,
-} from '@services/graphql/taxonomies';
import { NextPageWithLayout } from '@ts/types/app';
import { SubjectProps } from '@ts/types/taxonomies';
import { loadTranslation } from '@utils/helpers/i18n';
@@ -13,6 +9,10 @@ import Image from 'next/image';
import { ParsedUrlQuery } from 'querystring';
import { ReactElement } from 'react';
import styles from '@styles/pages/Subject.module.scss';
+import {
+ getAllSubjectsSlug,
+ getSubjectBySlug,
+} from '@services/graphql/queries';
const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
const getPostsList = () => {
@@ -68,7 +68,6 @@ interface PostParams extends ParsedUrlQuery {
export const getStaticProps: GetStaticProps = async (
context: GetStaticPropsContext
) => {
- console.log(context);
const translation = await loadTranslation(
context.locale!,
process.env.NODE_ENV === 'production'
@@ -85,7 +84,7 @@ export const getStaticProps: GetStaticProps = async (
};
export const getStaticPaths: GetStaticPaths = async () => {
- const allSlugs = await fetchAllSubjectsSlug();
+ const allSlugs = await getAllSubjectsSlug();
return {
paths: allSlugs.map((post) => `/sujet/${post.slug}`),